import { Login } from "@/api/login";
import { getUserId,setUserId} from "@/utils/usecookie";
const state={
   userId:getUserId()||"",
}
const getters={

}
const mutations={
    SET_USERID(state,value){
        state.userId=value
    },
}
const actions={
    async login({commit},requestData){
        const response = await Login(requestData);
        if(response.data.code!=-1){
        commit("SET_USERID",response.data.data.id)
        setUserId(response.data.data.id)
        return 0;
        }else{
            return -1;
        }
        }
}

export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
};